<?php 
 include_once dirname(__FILE__)."/config.php";
 class mention_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_CODE_MENTION;
		 protected $_NOM_MENTION;
		 protected $_CODE_DOMAINE;
		 public function get_name_table(){ return "mention";}
		 public function get_name_CODE_MENTION(){ return "CODE_MENTION";}
		 public function get_name_NOM_MENTION(){ return "NOM_MENTION";}
		 public function get_name_CODE_DOMAINE(){ return "CODE_DOMAINE";}
		 public function set_CODE_MENTION($parametre){  $this->_CODE_MENTION=$parametre;}	
		 public function set_NOM_MENTION($parametre){  $this->_NOM_MENTION=$parametre;}	
		 public function set_CODE_DOMAINE($parametre){  $this->_CODE_DOMAINE=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_CODE_MENTION(){ return $this->_CODE_MENTION;}
		 public function get_NOM_MENTION(){ return $this->_NOM_MENTION;}
		 public function get_CODE_DOMAINE(){ return $this->_CODE_DOMAINE;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 mention(
			NOM_MENTION,
			CODE_DOMAINE)
 VALUES(
			'".$this->_NOM_MENTION."',
			'".$this->_CODE_DOMAINE."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_NOM_MENTION)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NOM_MENTION='".$this->_NOM_MENTION."'";
}
if(!empty($this->_CODE_DOMAINE)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CODE_DOMAINE='".$this->_CODE_DOMAINE."'";
}
$sql="UPDATE 
mention SET 
 ".$sql."
								WHERE CODE_MENTION ='".$this->_CODE_MENTION."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
mention 
 
									WHERE CODE_MENTION ='".$this->_CODE_MENTION."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
mention ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		CODE_MENTION,
		NOM_MENTION,
		CODE_DOMAINE
 FROM 
 mention";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_CODE_MENTION=$row->CODE_MENTION;
		$this->_NOM_MENTION=$row->NOM_MENTION;
		$this->_CODE_DOMAINE=$row->CODE_DOMAINE;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>